package com.itheima02;

import java.util.ArrayList;
import java.util.Scanner;

public class Test02 {
    public static void main(String[] args) {
        String[] arr = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"};
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个1-7的整数:");
        int a = sc.nextInt();
        ArrayList<String> arr1 = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            arr1.add(arr[i]);
        }

        try {
            method(a, arr1);
        } catch (IndexOutOfBoundsException e) {
            // e.printStackTrace();
            System.out.println("输入错误!");
        }


    }

    public static void method(int a, ArrayList<String> arr1) throws IndexOutOfBoundsException {

        if (a < 1 || a > 7) {
            throw new IndexOutOfBoundsException("您输入的数据有误!");
        }
        String b = arr1.get(a - 1);
        System.out.println(b);

    }
}
